Let's know how communication works
between microservices firstly, when the client makes a request, it makes
communication with the product service, order service and customer service. Secondly the order service makes
communication with the product service and customer service. HTTP/1.1 is an example of
the default request you make when you use HTTP client libraries
such as axios and superagent. Now let's look at
the structure of the project. The customer micro service contains
customer related data such as customer id, name, address and its schema. DB Config will have a .js file
that will establish the connection with the Mongo database using mongoose. And the order service performs synchronous
communication with the customer and the product service to
retrieve order information. The product micro service contains
data related to the product service such as product ID,
name and its schema. Moving on to customer service. The file on the left is
the index.js file and the Customer Service runs on Port 4000. The index.js file will call
the customer router routing file. The file on the right is the customer
model.js file where the data will be saved on a mongo
database using mongoose. Now coming to the postman output for
customer service. In this example, the file type is Json. And all the data related to the customers
such as customer id, customer name, customer age and customer address
will be stored in the body. Here the status for the customer
request is 200, which means successful. Next is the product service. The example file on the left
is the index.js file And the product service runs on port 3000. The index.Js file will call
the product router routing file. The file on the right is
the product model .js file where the data will be saved on
a mongo database using mongoose. Now coming to the postman output for
product service. In this example, the file type is json and all the data related to
the products such as product ID, product name and product details
will be stored in the body. Here the status for the customer
request is 200, which means successful. Now let's learn about the order service. The example file on the left
is the index.js file and the order service runs on Port 5000. The index.js file will call
the order router routing file. The file on the right is
the order model.js file where the data will be saved on
a mongo database using mongoose. Let's now look at the postman output for
order service. Here the data related to
the order such as customer name, product name and product details
will be stored in the body. Here the status for the order request
is 200, which means successful.